<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            *{
                margin: 0px;
                padding: 0px;
                list-style: none;
            }
            ul{
                overflow: hidden;
            }
            li{
                float: left;
                width:120px;
                text-align: center;
                height: 30px;
                line-height: 30px;
                cursor: pointer;
            }
            div{
                width: 800px;
                height: 400px;
                text-align: center;
                line-height: 300px;
                border:1px solid red;
                display: none;
            }
            li.current{
                background:blue;
                color:white;
            }
            div.current{
                display: block;
            }
        </style>
    </head>
    <body>
        <ul>
            <li class="current">新闻</li>
            <li>娱乐</li>
            <li>头条</li>
            <li>视频</li>
            <li>游戏</li>
            <li>体育</li>
        </ul>
        <section>
            <div class="current">新闻内容</div>
            <div>娱乐内容</div>
            <div>头条内容</div>
            <div>视频内容</div>
            <div>游戏内容</div>
            <div>体育内容</div>
        </section>
 
        <script>
            var tags=document.getElementsByTagName('li');
            var boxs=document.getElementsByTagName('div');
            for(var i=0;i<tags.length;i++){
                tags[i].index=i;
                tags[i].onclick=function(){
                    for(var j=0;j<tags.length;j++){
                        tags[j].className=''
                        boxs[j].className=''
                    }
                    this.className='current';
                    var n=this.index;
                    boxs[n].className='current'
                }
            }
        </script>
    </body>
</html>
